<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resources/default/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="gps.general.label_#{logged.loggedIdiom}" var="label" />
                <f:loadBundle basename="gps.general.message_#{logged.loggedIdiom}" var="message" /> 
                <title><h:outputText value="#{label.title1}"/></title>
            </h:head>
        </ui:define>
        <ui:define name="autocomplete"><ui:include src="../autocomplete/main.xhtml"/></ui:define>

        <ui:define name="moduleTitle">#{label.title1}</ui:define>
        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <p:growl id="messages" showDetail="true"/>
            <h:form>  

                <h:panelGroup>
                    <!--IMEI -->
                    <div class="field">
                        <h:outputText value="#{label.field1}" class="label"/> 
                        <h:inputText id="imei" class="textfield" value="#{gps_general.imei}" size="50" maxlength="15" required="#{param['required']=='true'}" requiredMessage="#{message.m21}" disabled="#{gps_general.acceso()}" />
                        <h:outputText class="required" value="*"/>
                    </div>  
                    <!--NUMERO SERIE -->
                    <div class="field">
                        <h:panelGroup rendered="#{gps_general.accesoRendered()}" >
                            <h:outputText value="#{label.field2}" class="label" /> 
                            <h:inputText id="numero_serie" class="textfield" value="#{gps_general.numero_serie}" size="50" maxlength="200" required="#{param['required']=='true'}" requiredMessage="#{message.m22}" />
                            <h:outputText class="required" value="*" />
                        </h:panelGroup>
                    </div>

                    <!--Telefono -->
                    <div class="field">
                        <h:panelGroup rendered="#{gps_general.accesoRendered()}" >
                            <h:outputText value="#{label.field9}" class="label"/> 
                            <h:inputText id="telefono" class="textfield" value="#{gps_general.telefono}" size="8" maxlength="200" />
                        </h:panelGroup>
                    </div> 

                    <!--MARCA -->
                    <div class="field">
                        <h:panelGroup rendered="#{gps_general.accesoRendered()}" >
                            <h:outputText value="#{label.field3}" class="label"/> 
                            <h:inputText id="marca" class="textfield" value="#{gps_general.marca}" size="50" maxlength="200" required="#{param['required']=='true'}" requiredMessage="#{message.m23}"/>
                            <h:outputText class="required" value="*"/>
                        </h:panelGroup>
                    </div> 
                    <!--MODELO -->
                    <div class="field">
                        <h:panelGroup rendered="#{gps_general.accesoRendered()}" >
                            <h:outputText value="#{label.field4}" class="label"/> 
                            <h:inputText id="modelo" class="textfield" value="#{gps_general.modelo}" size="50" maxlength="20" required="#{param['required']=='true'}" requiredMessage="#{message.m24}" disabled="#{gps_general.acceso()}" />
                            <h:outputText class="required" value="*"/>
                        </h:panelGroup>
                    </div> 
                    <!--NOMBRE-->
                    <div class="field">
                        <h:outputText value="#{label.field5}" class="label"/> 
                        <h:inputText id="nombre" class="textfield" value="#{gps_general.nombre}" size="50" maxlength="20" />
                    </div> 
                    <!--TIPO -->
                    <div class="field">
                        <h:outputText value="#{label.field6}" class="label"/>
                        <h:selectOneMenu value="#{gps_general.tipo}" >  
                            <f:selectItem itemLabel="#{label.tipo1}" itemValue="1"/> 
                            <f:selectItem itemLabel="#{label.tipo2}" itemValue="2"/> 
                            <f:selectItem itemLabel="#{label.tipo3}" itemValue="3"/> 
                        </h:selectOneMenu>
                    </div>
                    <!--DETALLE -->
                    <div class="field">
                        <h:outputText value="#{label.field7}" class="label"/> 
                        <h:inputText id="detalle" class="textfield" value="#{gps_general.detalle}" size="50" maxlength="50" required="#{param['required']=='true'}" requiredMessage="#{message.m27}" />
                    </div> 
                    <!--CADUCIDAD -->
                    <div class="field">
                        <h:outputText value="#{label.field8}" class="label"/>
                        <p:calendar value="#{gps_general.caducidad}" effect="slide" navigator="true" readonlyInput="true" pattern="dd/MM/yy" yearRange="c-82:c+10" size="5" disabled="#{gps_general.acceso()}"/>
                        <h:outputText class="required" value="*"/>
                    </div>

                </h:panelGroup>
                <!--INSERTAR -->
                <h:commandButton value="#{label.button1}" class="button" actionListener="#{gps_general.insert}"  onclick="return verificar('#{message.m7}')" rendered="#{gps_general.accesoRendered()}">
                    <f:param name="required" value="true"/>
                </h:commandButton>
                <!--ACTUALIZAR -->
                <h:commandButton value="#{label.button2}" class="button" actionListener="#{gps_general.update}"  onclick="return verificar('#{message.m8}')">
                    <f:param name="required" value="true"/>
                </h:commandButton>
                <!--ELIMINAR -->
                <h:commandButton value="#{label.button3}" class="button" actionListener="#{gps_general.delete}" onclick="return verificar('#{message.m9}')" rendered="#{gps_general.accesoRendered()}" />
                <!--LIMPIAR -->
                <h:commandButton value="#{label.button4}" class="button" actionListener="#{gps_general.clear}" rendered="#{gps_general.accesoRendered()}" />
                <br/>


                <p:dataTable id="dataTable" var="gps" value="#{gps_generalFind.listByLoggedId}"
                             paginator="true" rows="10"
                             paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15,20"  rendered="#{gps_general.accesoRendered()}" >
                    <f:facet name="header">
                        #{label.title2}
                    </f:facet>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{label.field1}" />
                        </f:facet>
                        <h:outputText value="#{gps.imei}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{label.field2}" />
                        </f:facet>
                        <h:outputText value="#{gps.numero_serie}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{label.field3}" />
                        </f:facet>
                        <h:outputText value="#{gps.marca}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{label.field4}" />
                        </f:facet>
                        <h:outputText value="#{gps.modelo}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{label.field5}" />
                        </f:facet>
                        <h:outputText value="#{gps.nombre}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{label.field8}" />
                        </f:facet>
                        <p:calendar value="#{gps.caducidad}"  disabled="true" pattern="dd/MM/yy" yearRange="c-82:c+10" size="6" readonly="false"/>
                    </p:column>
                </p:dataTable>

            </h:form> 



        </ui:define>
    </ui:composition>
</html>
